﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.Windows.Forms;

namespace FormAuktionsHus
{
    class ClsSimpelServerSocket
    {
        ClsAuktionMonitor auktionMonitor;

        public ClsSimpelServerSocket(ClsAuktionMonitor auktionMonitor)
        {
            this.auktionMonitor = auktionMonitor;    
        }

        public void StartForbindelse()
        {
            IPAddress ip = IPAddress.Parse("127.0.0.1");
            TcpListener listener = new TcpListener(ip, 11000);
            listener.Start();

            while (true)
            {
                Socket clientSocket = listener.AcceptSocket();

                ClsClientHandler Client = new ClsClientHandler(clientSocket, auktionMonitor);
                Thread clientTråd = new Thread(Client.Run);
                clientTråd.IsBackground = true;
                clientTråd.Start();
            }
        }
    }
}

